package com.xinxing.learning.batch.jobexecutor;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.concurrent.atomic.AtomicInteger;

@Slf4j
@Component
public class DemoJobExecutor {

    private final AtomicInteger counts = new AtomicInteger();

    @XxlJob("demoJob")
    public void demoJob() {
        XxlJobHelper.log("XXL-JOB, Hello World.");
        // 打印日志
        log.info("[execute][定时第 ({}) 次执行]", counts.incrementAndGet());
    }
}
